package com.platform.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.platform.utils.StringUtils;
import lombok.Data;
import org.springframework.format.annotation.NumberFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;


/**
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2017-08-15 08:03:41
 */
@Data
public class UserTransactionRecordVo implements Serializable {
    private static final long serialVersionUID = 1L;

    public static final String TRANSACTION_TYPE_REBATES             =   "1";        //折扣返点
    public static final String TRANSACTION_TYPE_PAY_WX              =   "2";        //微信支付
    public static final String TRANSACTION_TYPE_PAY_ACCOUNT         =   "3";        //余额支付
    public static final String TRANSACTION_TYPE_WITHDRAW            =   "4";        //提现
    public static final String TRANSACTION_TYPE_ADD_COMMISSION      =   "5";        //后台增加佣金
    public static final String TRANSACTION_TYPE_CANCEL_REBATES      =   "6";        //撤销折扣返点
    public static final String TRANSACTION_TYPE_REFUND              =   "7";        //后台退款余额

    //主键
    private Long id;

    private Long user_id;

    private Long transaction_user_id;

    private String type;

    private String money;

    private Integer order_id;

    private Integer order_goods_id;

    private String transaction_user_name;

    private String avatar;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date time;

    private String remark;

    public String getTypeDesc(){
        if (StringUtils.isNullOrEmpty(type)){
            return "";
        } else if (type.equals(TRANSACTION_TYPE_REBATES)){
            return "折扣返点";
        } else if (type.equals(TRANSACTION_TYPE_PAY_WX)){
            return "微信支付";
        } else if (type.equals(TRANSACTION_TYPE_PAY_ACCOUNT)){
            return "余额支付";
        } else if (type.equals(TRANSACTION_TYPE_WITHDRAW)){
            return "提现";
        } else if (type.equals(TRANSACTION_TYPE_ADD_COMMISSION)){
            return "后台增加佣金";
        } else if (type.equals(TRANSACTION_TYPE_CANCEL_REBATES)){
            return "撤销折扣返点";
        } else if (type.equals(TRANSACTION_TYPE_REFUND)){
            return "后台退款";
        }
        return "";
    }

    public String getMoneyFormat(){
//        if (money == null){
//            return "";
//        } else {
//            return money.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
//        }
        return money;
    }


}
